﻿using System.Collections.Generic;
using System.Linq;
using BusinessLogic.Connectivity.Entities;
using DataAccess.Services;

namespace BusinessLogic.Mappers.DocumentEnvelopes
{
	internal class DocumentEnvelopeMapper : MapperBase<DocumentEnvelope, DataControl.Document_Envelope>, IDocumentEnvelopeMapper
	{
		public DocumentEnvelopeMapper(IServiceManager serviceManager, IMapping<DocumentEnvelope, DataControl.Document_Envelope> mapping, IGatewayBase<DataControl.Document_Envelope> gatewayBase)
			: base(serviceManager, gatewayBase, mapping)
		{
		}

		public IEnumerable<DocumentEnvelope> SelectReceivedEnvelopes()
		{
			return ServiceManager.DocumentEnvelope.SelectSentEnvelopes().Select(dto => Mapping.ToBE(dto));
		}

		public IEnumerable<DocumentEnvelope> SelectBySenderId(int senderId)
		{
			return ServiceManager.DocumentEnvelope.SelectEnvelopesBySender(senderId).Select(row => Mapping.ToBE(row));
		}

		public IList<DocumentEnvelope> GetAll()
		{
			return ServiceManager.DocumentEnvelope.GetAll().Select(row => Mapping.ToBE(row)).ToList();
		}
	}
}
